﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

using Global.Class.Library;

namespace DataTransferObject
{
    public class MarketingIncentiveDetail : NotifyPropertyChangeObject
    {
        private int marketingIncentiveID;      
        private int serialID;

        private int customerID;
        private int marketingPaymentTermID;

        private double turnOverAmount;
        private double incentiveAmount;

        private string description;
        private string remarks;


        public MarketingIncentiveDetail()
            : this(-1,-1, -1, 0, 0, 0, "", "")
        {
        }

        public MarketingIncentiveDetail(int marketingIncentiveID, int serialID, int customerID, int marketingPaymentTermID, double turnOverAmount, double incentiveAmount, string description, string remarks)
        {
            GlobalDefaultValue.Apply(this);

            this.MarketingPaymentTermID = marketingPaymentTermID;

            this.MarketingIncentiveID = marketingIncentiveID;
            this.SerialID = serialID;
            this.CustomerID = customerID;

            this.TurnOverAmount = turnOverAmount;
            this.IncentiveAmount = incentiveAmount;

            this.Description = description;
            this.Remarks = remarks;
        }


        #region Properties

        [DefaultValue(-1)]
        public int MarketingIncentiveID
        {
            get { return this.marketingIncentiveID; }
            set { ApplyPropertyChange<MarketingIncentiveDetail, int>(ref this.marketingIncentiveID, o => o.MarketingIncentiveID, value); }
        }

        [DefaultValue(-1)]
        public int SerialID
        {
            get { return this.serialID; }
            set { ApplyPropertyChange<MarketingIncentiveDetail, int>(ref this.serialID, o => o.SerialID, value); }
        }

        [DefaultValue(-1)]
        public int CustomerID
        {
            get { return this.customerID; }
            set { ApplyPropertyChange<MarketingIncentiveDetail, int>(ref this.customerID, o => o.CustomerID, value); }
        }

        [DefaultValue(0)]
        public int MarketingPaymentTermID
        {
            get { return this.marketingPaymentTermID; }
            set { ApplyPropertyChange<MarketingIncentiveDetail, int>(ref this.marketingPaymentTermID, o => o.MarketingPaymentTermID, value); }
        }


        [DefaultValue(0)]
        public double TurnOverAmount
        {
            get { return this.turnOverAmount; }
            set { ApplyPropertyChange<MarketingIncentiveDetail, double>(ref this.turnOverAmount, o => o.TurnOverAmount, Math.Round(value, GlobalVariables.Round0Amount)); }
        }

        [DefaultValue(0)]
        public double IncentiveAmount
        {
            get { return this.incentiveAmount; }
            set { ApplyPropertyChange<MarketingIncentiveDetail, double>(ref this.incentiveAmount, o => o.IncentiveAmount, Math.Round(value, GlobalVariables.Round0Amount)); }
        }



        [DefaultValue("")]
        public string Description
        {
            get { return this.description; }
            set { ApplyPropertyChange<MarketingIncentiveDetail, string>(ref this.description, o => o.Description, value); }
        }

        [DefaultValue("")]
        public string Remarks
        {
            get { return this.remarks; }
            set { ApplyPropertyChange<MarketingIncentiveDetail, string>(ref this.remarks, o => o.Remarks, value); }
        }

        #endregion


        protected override System.Collections.Generic.List<ValidationRule> CreateRules()
        {
            List<ValidationRule> validationRules = base.CreateRules();
            validationRules.Add(new SimpleValidationRule("CustomerID", "Please fill a customer code.", delegate { return  this.CustomerID > 0; }));
            validationRules.Add(new SimpleValidationRule("MarketingPaymentTermID", "Please select a payment term.", delegate { return this.MarketingPaymentTermID > 0; }));
            
            return validationRules;
        }
    }
}
